package com.example.math_exam.MVC.acttivity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.math_exam.MVC.BaseActivity;
import com.example.math_exam.R;
import com.example.math_exam.ShopEntitiy;

import java.util.ArrayList;

public class MainActivity extends BaseActivity implements View.OnClickListener {

    private ImageView mHeadBack;
    private ImageView mMainIcon;
    private TextView mMainName;
    private TextView mMainPrice;
    private ShopEntitiy shop;
    private TextView mainGWC;

    @Override
    protected int getLayoutID() {
        return R.layout.activity_main;
    }

    @Override
    protected void initActivity() {

        mHeadBack = f(R.id.head_back);
        mMainIcon = f(R.id.main_icon);
        mMainName = f(R.id.main_name);
        mMainPrice = f(R.id.main_price);
        mainGWC = f(R.id.main_gwc);

        shop = new ShopEntitiy("1", R.drawable.icon, "LANEIGE兰芝", 138);
    }

    @Override
    protected void setOperation() {

        mMainIcon.setImageResource( shop.getIcon());
        mMainName.setText( shop.getName());
        mMainPrice.setText(  "￥" +  shop.getPrice());
    }

    @Override
    protected void setListener() {

        mainGWC.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        switch ( v.getId()) {
            case R.id.main_gwc:

                Intent intent = new Intent(this, GwdActivity.class);
                intent.putExtra( "shop", shop);
                startClass(intent);
                break;
        }
    }
}
